#!/usr/bin/env python

#configuration.py

import pygtk
pygtk.require('2.0')
import gtk

class Configuration:
   
    def enter_callback(self, widget, entry):
        entry_text = entry.get_text()
        print "Entry contents: %s\n" % entry_text

    def click_callback(self, widget, data=None):
        gtk.main_quit()
        
    def cancel_callback(self, widget, data=None):
        gtk.main_quit()
             
    def __init__(self):
        # create a new window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("destroy", lambda w: gtk.main_quit())
    
        # Set the title of the window
        self.window.set_title("Login Page")

        # Sets the border the Window
        self.window.set_border_width(100)

        # Create a box to hold the labels
        hbox = gtk.HBox(False,0)
        vbox = gtk.VBox(False,0)
        self.window.add(vbox)

        # Create a "Username" label
        label = gtk.Label("Username")
        label.set_justify(gtk.JUSTIFY_CENTER)
        vbox.pack_start(label, False, False, 10)

        # Create Text Entry for username
        entry = gtk.Entry()
        entry.set_max_length(20)
        entry.set_text("tjohns")
        entry.connect("activate", self.enter_callback, entry)
        vbox.pack_start(entry, False, False, 10)
        
        # Create a "Domain" label
        label = gtk.Label("Domain")
        label.set_justify(gtk.JUSTIFY_CENTER)
        vbox.pack_start(label, False, False, 10)

        # Create Text Entry for domain
        entry = gtk.Entry()
        entry.set_max_length(20)
        entry.set_text("usc.olpc")
        entry.connect("activate", self.enter_callback, entry)
        vbox.pack_start(entry, False, False, 10)

        # Create a "Password" label
        label = gtk.Label("Password")
        label.set_justify(gtk.JUSTIFY_CENTER)
        vbox.pack_start(label, False, False, 10)

        # Create Text Entry for password
        entry = gtk.Entry()
        entry.set_max_length(20)
        entry.set_text("test123c")
        entry.set_visibility(False)
        entry.connect("activate", self.enter_callback, entry)
        vbox.pack_start(entry, False, False, 10)

        # Create a "OK" button
        bbox = gtk.HButtonBox()
        bbox.set_border_width(5)
        bbox.set_spacing(40)
        button = gtk.Button(stock=gtk.STOCK_OK)
        button.connect("clicked", self.click_callback, "OK button")
        bbox.add(button)

        # Create a "CANCEL" button
        button = gtk.Button(stock=gtk.STOCK_CANCEL)
        button.connect("clicked", self.cancel_callback, "CANCEL button")
        bbox.add(button)
        hbox.pack_start(bbox, False, False, 30)

        vbox.pack_start(hbox, False, False, 50)        
        
        self.window.show_all()


def main():
    gtk.main()

if __name__ == "__main__":
    configuration = Configuration()
    main()
